package JLB_Chapter_09;

import java.util.Scanner;

public class code_09_10 {
    public static void main(String[] args) {
        System.out.println("--------猜数字游戏--------");
        int iNum;
        int iGuess;
        Scanner in = new Scanner(System.in);
        // 生成0-100之间的随机数
        iNum = (int) (Math.random() * 100);
        System.out.println("请输入你猜的数字：");
        iGuess = in.nextInt();
        while((iGuess != -1) && (iGuess != iNum)) {
            if(iGuess < iNum) {
                System.out.println("太小，请重新输入");
                iGuess = in.nextInt();
            } else {
                System.out.println("太大，请重新输入");
                iGuess = in.nextInt();
            }
        }
        if(iGuess == -1) {
            System.out.println("退出游戏！");
        } else {
            System.out.println("恭喜你，你赢了！猜中的数字为：" + iNum);
        }
    }
}
